package javabasics.designpattern.singleton;

/**
 * 最基础的单例模式
 *
 * @Author suxiaoxiao
 * @Date 2019/5/30 22:43
 * @Version 1.0
 */
public class Singleton {

    /**
     * 私有化构造器是单例的标准
     */
    private Singleton() {
        System.out.println("Singleton is create");
    }

    /**
     * 因为是静态属性，所以JVM加载类的时候会被创建。
     */
    private static Singleton instance = new Singleton();

    public static Singleton getInstance() {
        return instance;
    }

    public static void createString() {
        System.out.println("creatingString in Singleton");
    }

}
